/**
 * 
 */
package org.softTank.BC.entity.services;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.softTank.BC.entity.IdEntity;

/**
 * @author Yuzone
 *
 */
@Entity
@Table(name = "SSDB_PORTTYPE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class PortType extends IdEntity {

	private String name;
	private String namespace;
	private String location;
	private String description;
	private List<Operation> operationList;
	private List<Role> roleList;

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(nullable = false)
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	@Column(nullable = false)
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Column
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "SSDB_PORTTYPE_OPERATION", joinColumns = { @JoinColumn(name = "PORTTYPE_ID") }, inverseJoinColumns = { @JoinColumn(name = "OPERATION_ID") })
	@Fetch(FetchMode.SUBSELECT)
	@OrderBy("id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Operation> getOperationList() {
		return operationList;
	}

	public void setOperationList(List<Operation> operationList) {
		this.operationList = operationList;
	}

	@OneToMany
	@JoinTable(name = "SSDB_ROLE_PORTTYPE", joinColumns = { @JoinColumn(name = "PORTTYPE_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
	@Fetch(FetchMode.SUBSELECT)
	@OrderBy("id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Role> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}
}
